/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-09
 * Time:16:25
 */
public class MyTest {
    public static int getElement(int[] array, int index){
        if(null == array){
            throw new NullPointerException("传递的数组为null");}
        if(index < 0 || index >= array.length){
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }
        return array[index];
    }
    public static int get(){
        try{
            System.out.println("try里面的s");
            int[] arr=null;
            System.out.println(arr[0]);//遇到错误直接catch
            return 0;//所以这个没有执行
        }catch (NullPointerException e){
            System.out.println("catch里面的s");
            return 0;//这个执行了，但是发现还有finally
        }finally{
            System.out.println("finally里面的s");
            return 0;
        }
        //return 0;
    }

    public static void main(String[] args) {
        int a=get();
    }
    public static void main1(String[] args) {
        int[] array = {1,2,3};
        getElement(array, 3);
    }

}
